package com.zs.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.system.common.mapper.BisShopUserMapper;
import com.system.common.pojo.BisShopUser;
import com.system.common.pojo.BisShopUserExample;
import com.system.common.pojo.BisShopUserExample.Criteria;

@Service
public class BisShopUserServiceImpl implements BisShopUserService{
	@Autowired
	private BisShopUserMapper bisShopUserMapper;

	@Override
	public List<BisShopUser> queryBisShopUser(Map<String, Object> map) {
		String bisaccount=(String)map.get("bisaccount");
		String bisname=(String)map.get("bisname");
		String postEmp=(String)map.get("postEmp");
		String workNumber=(String)map.get("workNumber");
		String phone=(String)map.get("phone");
		Date stateDate=(Date) map.get("stateDate");
		Date endDate=(Date)map.get("endDate");
		String shopId=(String)map.get("shopId");
		BisShopUserExample example=new BisShopUserExample();
		//初始化一个查询条件
		Criteria criteria=example.createCriteria();
		if (StringUtils.isNotBlank(bisaccount)) {
			criteria.andAccountLike("%"+bisaccount+"%");
		}
		if (!StringUtils.isBlank(bisname)) {
			criteria.andUsernameLike("%"+bisname+"%");
		}
		if (!StringUtils.isBlank(postEmp)) {
			criteria.andPostCodeEqualTo(postEmp);
		}
		if (!StringUtils.isBlank(workNumber)) {
			criteria.andWorkNumberLike("%"+workNumber+"%");
		}
		if (!StringUtils.isBlank(phone)) {
			criteria.andMobileLike("%"+phone+"%");
		}
		if (StringUtils.isNotBlank(shopId)) {
			criteria.andShopIdEqualTo(shopId);
		}
		if (stateDate!=null&&!stateDate.equals("")&&endDate!=null&&!endDate.equals("")) {
			criteria.andEntryDateBetween(stateDate, endDate);
		}
		List<BisShopUser> bisShopUsers=this.bisShopUserMapper.selectByExample(example);
		return bisShopUsers;
	}

	@Override
	public BisShopUser queryBisShopUserById(String shopUserId) {
		BisShopUser bisShopUser=this.bisShopUserMapper.selectByPrimaryKey(shopUserId);
		return bisShopUser;
	}
    
}
